class Solution {
public:
    vector<int> ans;

    void traverse(TreeNode *root) {
        if (!root) return; 
        
        traverse(root->left);
        traverse(root->right);
        ans.push_back(root->val);
    }
    
    vector<int> postorderTraversal(TreeNode* root) {
        traverse(root);
        return ans;

    }
};